<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import Home from './Home/index.vue'

const route = ref('')
const enterAction = ref({})

onMounted(() => {
  window.utools.onPluginEnter((action) => {
    if(action.code === 'closeAll') {
      window.messageBus.publish({
        type: 'closeAll',
        data: null
      })
      window.utools.hideMainWindow();
      window.utools.outPlugin(true)
    }
    if(action.code === 'hide') {
      window.messageBus.publish({
        type: 'hide',
        data: null
      })
    }
    if(action.code === 'show') {
      window.messageBus.publish({
        type: 'show',
        data: null
      })
    }

    route.value = action.code
    enterAction.value = action
  })
  window.utools.onPluginOut((isKill) => {
    route.value = ''
  })
})
</script>

<template>
  <template v-if="route === 'home'">
    <Home :enterAction="enterAction"></Home>
  </template>
</template>
